 <%@ page import="java.util.*" contentType="text/html"%>
<%@ page import="model.Measurement" contentType="text/html"%>
 <script type="text/javascript" src="https://www.google.com/jsapi"></script>
	<script type="text/javascript" src="http://www.google.com/jsapi"></script>
            <script type="text/javascript">
			  google.load('visualization', '1', {packages: ['corechart']});
			</script> 

				<script type="text/javascript">
				
				// VOOR HET TEKENEN VAN DE GRAFIEK
				
                  function drawVisualization() {
		              var data = new google.visualization.DataTable();
		              data.addColumn('string', 'Year');
		              data.addColumn('number', 'Deur');      
		      		  
		              <% 
		              int dagen = 1;
		              if(request.getAttribute("dagenVerschil") == null){
		              } else{
		              	  dagen = (Integer)request.getAttribute("dagenVerschil");
		              }
		            	  if(dagen != -1 && request.getAttribute("dagenLijst") != null && request.getAttribute("door") != null){
		      		  			int[] urenWaardes = (int[])request.getAttribute("dagenLijst");
		      		  			int[][] waardes = (int[][])request.getAttribute("door");
		      		  		    dagen = (Integer)request.getAttribute("dagenVerschil");
		      		  		     
		      		  		    for(int x = 0; x < dagen; x++){
		          	 	 			for(int i = 0; i<urenWaardes.length; i++){	%>
		          						var date = '<%= urenWaardes[i] %>';
		          	 					var getal = <%= waardes[x][i]%>;
		          						data.addRows([[ date , getal]]  );
		          	 	 	<%  }   } 
    	 	  }else if(request.getAttribute("dagenLijst") == null &&  !request.getAttribute("eersteKeer").equals("eersteKeer") && (Integer)request.getAttribute("keerGedaan") <1 ){
    	 		  request.setAttribute("keerGedaan", (Integer)request.getAttribute("keerGedaan") +1 ); %>
    	 		 alert("kan niet meer dan 28 dagen verschil zijn"); <%
    	 	  } else if( !request.getAttribute("eersteKeer").equals("eersteKeer") && (Integer)request.getAttribute("keerGedaan") <1 ){
          	 	  request.setAttribute("keerGedaan", (Integer)request.getAttribute("keerGedaan") +1 ); %>
						alert("geen geldige invoer");
          	   <% } %>
		          	  
		              // Create and draw the visualization.
		          	var ac = new google.visualization.AreaChart(document.getElementById('DoorGraph'));
		            ac.draw(data, {
		              isStacked: true,
		              width: 600,
		              height: 400, 
		              vAxis: {title: 'Deur', minValue: 0, maxValue: 2},
		              hAxis: {title: "Uren"}
		            });
            	}
          google.setOnLoadCallback(drawVisualization);
      </script>